package com.fh.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Peanut on 2017/12/20.
 * 项目状态枚举
 */
public enum ProjectStateEnum {
	CREATE("创建", 1),
    ONAUDIT("审核中", 2),
    NOAUDIT("审核未通过", 3),
    ADOPT("通过", 4),
    DELIVERY("投递", 5),
    REVIEW("会审", 6),
    INTERVIEW("约谈", 7);

    /** 描述 */
    private String desc;

    /** 枚举值 */
    private Integer value;

    ProjectStateEnum(String desc, Integer value) {
        this.desc = desc;
        this.value = value;
    }

    public Byte getByteValue(){
        return Byte.parseByte(getValue().toString());
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static ProjectStateEnum getEnum(Integer value){
        ProjectStateEnum resultEnum = null;
        ProjectStateEnum[] enumAry = ProjectStateEnum.values();
        for(int i = 0;i<enumAry.length;i++){
            if(enumAry[i].getValue().equals(value)){
                resultEnum = enumAry[i];
                break;
            }
        }
        return resultEnum;
    }

    public static Map<String, Map<String, Object>> toMap() {
        ProjectStateEnum[] ary = ProjectStateEnum.values();
        Map<String, Map<String, Object>> enumMap = new HashMap<String, Map<String, Object>>();
        for (int num = 0; num < ary.length; num++) {
            Map<String, Object> map = new HashMap<String, Object>();
            String key = String.valueOf(getEnum(ary[num].getValue()));
            map.put("value", ary[num].getValue());
            map.put("desc", ary[num].getDesc());
            enumMap.put(key, map);
        }
        return enumMap;
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static List<Map<String, String>> toList(){
        ProjectStateEnum[] ary = ProjectStateEnum.values();
        List list = new ArrayList();
        for(int i=0;i<ary.length;i++){
            Map<String,String> map = new HashMap<String,String>();
            map.put("value",ary[i].getValue().toString());
            map.put("desc", ary[i].getDesc());
            list.add(map);
        }
        return list;
    }

}
